<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>instanceof</title>
</head>
<body>
<script type="text/javascript">
function myInstanceof(obj1, obj2) {
	let proto1 = Object.getPrototypeOf(obj1);
	let proto2 = obj2.prototype;
	let queue = [proto1];
	// 递归原型链
	while(queue.length) {
		let temp = queue.shift();
		if(temp === null) return false;
		if(temp === proto2) return true;
		queue.push(Object.getPrototypeOf(temp));
	}
	return false;
}
console.log(myInstanceof(new Date(), Date));//true
console.log(myInstanceof(11, Number));//true
console.log(myInstanceof('11', Number));//false
</script>
</body>
</html>